package com.skwen.delivery.superdelivery.deliveryOrder.bean;

import com.skwen.delivery.superdelivery.myGreenDao.DaoSession;
import com.skwen.delivery.superdelivery.myGreenDao.ExpressInfoDao;
import com.skwen.delivery.superdelivery.myGreenDao.OrderDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;

/**
 * Created by skwen on 2017/11/25.
 * SuperDelivery
 */

@Entity
public class Order {


    @Id
    private long id;

    private String sendTime;

    private long orderId;

    @ToOne(joinProperty = "orderId")
    private ExpressInfo expressInfo;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 949219203)
    private transient OrderDao myDao;

    @Generated(hash = 1704390798)
    public Order(long id, String sendTime, long orderId) {
        this.id = id;
        this.sendTime = sendTime;
        this.orderId = orderId;
    }

    @Generated(hash = 1105174599)
    public Order() {
    }

    public long getId() {
        return this.id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getSendTime() {
        return this.sendTime;
    }

    public void setSendTime(String sendTime) {
        this.sendTime = sendTime;
    }

    public long getOrderId() {
        return this.orderId;
    }

    public void setOrderId(long orderId) {
        this.orderId = orderId;
    }

    @Generated(hash = 1487139812)
    private transient Long expressInfo__resolvedKey;

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 2113109825)
    public ExpressInfo getExpressInfo() {
        long __key = this.orderId;
        if (expressInfo__resolvedKey == null
                || !expressInfo__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ExpressInfoDao targetDao = daoSession.getExpressInfoDao();
            ExpressInfo expressInfoNew = targetDao.load(__key);
            synchronized (this) {
                expressInfo = expressInfoNew;
                expressInfo__resolvedKey = __key;
            }
        }
        return expressInfo;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 2026145535)
    public void setExpressInfo(@NotNull ExpressInfo expressInfo) {
        if (expressInfo == null) {
            throw new DaoException(
                    "To-one property 'orderId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.expressInfo = expressInfo;
            orderId = expressInfo.getId();
            expressInfo__resolvedKey = orderId;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 965731666)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getOrderDao() : null;
    }




}
